/// Created by XieXin on 2020/11/11.
/// 正则验证
class RegExpUtils {
  ///手机号正则
  static const String regExpMobile =
      r"^1([38][0-9]|4[579]|5[0-3,5-9]|6[6]|7[0135678]|9[89])\d{8}$";

  ///邮箱正则
  static const String regExpEmail =
      r"^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$";

  ///URL正则
  static const String regExpUrl = r"^((https|http|ftp|rtsp|mms)?:\/\/)[^\s]+";

  ///简单身份证正则
  static const String regExpIdCardEasy = r"\d{17}[\d|x]|\d{15}";

  ///身份证正则
  static const String regExpIdCard =
      r"^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$";

  ///中文正则
  static const String regExpChinese = r"[\u4e00-\u9fa5]";

  ///手机号验证
  static bool isChinaPhoneLegal(String str) {
    return RegExp(regExpMobile).hasMatch(str);
  }

  ///邮箱验证
  static bool isEmail(String str) {
    return RegExp(regExpEmail).hasMatch(str);
  }

  ///验证URL
  static bool isUrl(String value) {
    return RegExp(regExpUrl).hasMatch(value);
  }

  ///简单验证身份证
  static bool isIdCardEasy(String value) {
    return RegExp(regExpIdCardEasy).hasMatch(value);
  }

  ///验证身份证
  static bool isIdCard(String value) {
    return RegExp(regExpIdCard).hasMatch(value);
  }

  ///验证中文
  static bool isChinese(String value) {
    return RegExp(regExpChinese).hasMatch(value);
  }
}
